//
//  MidTools.m
//  A段项目,漫画
//
//  Created by dllo on 15/4/28.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "MidTools.h"

@implementation MidTools


+ (instancetype)shareMidTools{
    static MidTools *midtools = nil;
    static dispatch_once_t oneToTake;
    dispatch_once(&oneToTake, ^{
        midtools = [[MidTools alloc] init];
        midtools.isFinish = NO;
        midtools.searchMark = [NSMutableArray array];
        midtools.isSearchMarkShow = NO;
    });
    return midtools;
}


//搜索
- (void)searchByUrl:(NSString *)url{
    self.result = [NSMutableArray array];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSMutableDictionary *dic = responseObject;
        NSMutableArray *dataArr = dic[@"data"];
        for (NSMutableDictionary *d in dataArr) {
            cartoonDestai *cd = [[cartoonDestai alloc] init];
            [cd setValuesForKeysWithDictionary:d];
            [self.result addObject:cd];
            [cd release];
        }
        NSLog(@"数据请求成功");
        NSLog(@"数据个数:%ld",self.result.count);
        //数据解析完成之后发送信号
        self.isFinish = YES;
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"数据请求失败");
    }];
}

@end
